package com.pair.micro.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/** 业务异常 非0开头 */
@Getter
@AllArgsConstructor
public enum MicroBusinessError {
  BIS_10001("10001", "参数为空"),
  BIS_10002("10002", "参数格式不正确"),
  BIS_10003("10003", "参数中包含敏感词"),
  BIS_10004("10004", "参数已存在"),
  BIS_10005("10005", "参数不存在"),
  BIS_10006("10006", "参数不合法"),
  BIS_10007("10007", "参数错误"),

  BIS_10101("10101", "授权key为空"),
  BIS_10102("10102", "授权secret为空"),
  BIS_10103("10103", "授权token为空"),
  BIS_10104("10104", "授权key不合法"),

  BIS_20001("20001", "单条记录查询无数据"),
  BIS_20002("20002", "多条记录查询无数据"),
  BIS_20003("20003", "分页记录查询无数据"),
  BIS_20010("20010", "新增数据失败"),
  BIS_20011("20011", "修改数据失败"),
  BIS_20012("20012", "删除数据失败"),
  BIS_20013("20013", "查询数据失败"),
  BIS_20014("20014", "合并数据失败"),
  BIS_20015("20015", "拆分数据失败"),
  BIS_20020("20020", "无查询数据权限"),
  BIS_20021("20021", "无新增数据权限"),
  BIS_20022("20022", "无修改数据权限"),
  BIS_20023("20023", "无删除数据权限"),
  BIS_20040("20040", "存在下级及联数据"),
  BIS_20041("20041", "存在上级及联数据"),
  BIS_20042("20042", "上级机构不能为自身"),
  BIS_20043("20043", "上级机构不能为下级"),
  BIS_20044("20044", "机构下存在子机构"),
  BIS_20045("20045", "机构下面存在用户"),
  BIS_20046("20046", "上级菜单不能为自身"),

  BIS_20101("20101", "数据加密失败"),
  BIS_20102("20102", "数据解密失败"),

  BIS_30001("30001", "状态不能变更"),
  BIS_30002("30002", "账户余额不足"),
  BIS_30003("30003", "账户积分不足"),
  BIS_30004("30004", "已绑定手机号"),
  BIS_30005("30005", "未绑定手机号"),
  BIS_30006("30006", "手机号不存在"),
  BIS_30007("30007", "手机号已存在"),
  BIS_30008("30008", "用户名已经存在"),


  BIS_30010("30010", "验证码已发送"),
  BIS_30011("30011", "验证码数量已达上限"),
  BIS_30012("30012", "验证码错误"),
  BIS_30013("30013", "验证码已过期"),
  BIS_30014("30014", "请重新发送验证码"),
  BIS_30015("30015", "手机号或验证码错误"),

  BIS_30021("30021", "短信发送数量已达上限"),
  BIS_30022("30022", "阿里云短信剩余数量不足"),
  BIS_30023("30023", "阿里云短信剩余数量为零"),
  BIS_30024("30024", "阿里云短信剩余数量不足,微信验证码发送成功"),
  BIS_30025("30025", "阿里云短信剩余数量为零,微信验证码发送成功"),
  BIS_30026("30026", "公司未购买短信包,微信验证码发送成功"),
  BIS_30027("30027", "公司未购买短信包,微信未开启安全验证"),

  BIS_30050("30050", "重复操作"),
  BIS_30051("30051", "非法操作"),
  BIS_30052("30052", "越权操作"),
  BIS_30053("30053", "超时操作"),
  BIS_30054("30054", "无权操作"),
  BIS_30055("30055", "无效操作"),

  BIS_40010("40010", "请重新登录"),
  BIS_40011("40011", "密码与确认密码不一致"),
  BIS_40012("40012", "账号或密码错误"),
  BIS_40013("40013", "登录密码错误"),
  BIS_40014("40014", "支付密码错误"),
  BIS_40015("40015", "未设置支付密码"),
  BIS_40016("40016", "未设置登录密码"),
  BIS_40017("40017", "请重新发送快捷登录验证码"),

  BIS_50001("50001", "未查到需要付费的房屋"),

  BIS_50002("50002", "未创建收费项"),

  BIS_50003("50003", "重复缴费")
  ;

  private String code;
  private String msg;

  /**
   * 根据编码查询异常信息
   *
   * @param code
   * @return
   */
  public static MicroBusinessError getBisError(String code) {
    for (MicroBusinessError microBusinessError : values()) {
      if (microBusinessError.getCode().equals(code)) {
        return microBusinessError;
      }
    }
    return null;
  }
}
